//https://leetcode.cn/problems/minimum-depth-of-binary-tree/

int minDepth(struct TreeNode* root) {
    if (root == NULL)
    {
        return 0;
    }
    int left = minDepth(root->left);
    int right = minDepth(root->right);
    if (root->right == NULL && root->left != NULL)
    {
        return left + 1;
    }
    else if (root->left == NULL && root->right != NULL)
    {
        return right + 1;
    }
    else
    {
        return left < right ? left + 1 : right + 1;
    }

}